package com.xbongbong.saas.enums;

import com.xbongbong.saas.enums.business.*;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * 移动端详情页再要显示字段
 *
 * @author GuoJun.HU
 * @date 2019/3/12 16:53
 * @since V1.0
 */
@Getter
public enum MobileDetailSummaryEnum {

    // 移动端详情页再要显示字段
    CUSTOMER(RedundantTemplateTypeEnum.CUSTOMER.getCode(), Collections.singletonList(CustomerManagementEnum.LAST_CONNECT_TIME)),
    CONTRACT(RedundantTemplateTypeEnum.CONTRACT.getCode(), Arrays.asList(ContractEnum.NAME, ContractEnum.SIGN_PERSON, ContractEnum.SIGN_TIME)),
    SALES_OPPORTUNITY(RedundantTemplateTypeEnum.SALES_OPPORTUNITY.getCode(), Arrays.asList(SalesOpportunityEnum.SERIAL_NO, SalesOpportunityEnum.ESTIMATE_END_TIME)),
    PAYMENT(RedundantTemplateTypeEnum.PAYMENT.getCode(), Arrays.asList(PaymentEnum.CONTRACT_LINK_TEXT, PaymentEnum.ESTIMATE_TIME, PaymentEnum.PAYMENT_TYPE, PaymentEnum.MEMO)),
    PAY_PLAN(RedundantTemplateTypeEnum.PAY_PLAN.getCode(), Arrays.asList(PayPlanEnum.LINK_PURCHASE_LINK_TEXT, PayPlanEnum.ESTIMATE_TIME, PayPlanEnum.PAY_TYPE, PayPlanEnum.MEMO)),
    INVOICE(RedundantTemplateTypeEnum.INVOICE.getCode(), Arrays.asList(InvoiceEnum.INVOICE_DATE, InvoiceEnum.TOTAL_MONEY)),
    CONTACT(RedundantTemplateTypeEnum.CONTACT.getCode(), Arrays.asList(ContactEnum.DEPARTMENT, ContactEnum.POSITION, ContactEnum.PHONE)),
    SUPPLIER_CONTACT(RedundantTemplateTypeEnum.SUPPLIER_CONTACT.getCode(), Arrays.asList(SupplierContactEnum.DEPARTMENT, SupplierContactEnum.POSITION, SupplierContactEnum.PHONE)),
    PURCHASE(RedundantTemplateTypeEnum.PURCHASE.getCode(), Arrays.asList(PurchaseEnum.SIGN_TIME, PurchaseEnum.ESTIMATE_ARRIVE_TIME)),
    RETURNED_PURCHASE(RedundantTemplateTypeEnum.RETURNED_PURCHASE.getCode(), Arrays.asList(ReturnedPurchaseEnum.PURCHASE_SHEET_ID_LINKED_TEXT, ReturnedPurchaseEnum.TIME)),
    SUPPLIER(RedundantTemplateTypeEnum.SUPPLIER.getCode(), Arrays.asList(SupplierEnum.QUALITY_STANDARD, SupplierEnum.SUPPLY_COST, SupplierEnum.DELIVERY_CAPACITY, SupplierEnum.SERVER_CAPACITY, SupplierEnum.CREDIT_LEVEL)),
    WAREHOUSE(RedundantTemplateTypeEnum.WAREHOUSE.getCode(), Arrays.asList(WarehouseEnum.WAREHOUSE_NO, WarehouseEnum.ADDRESS, WarehouseEnum.MEMO, WarehouseEnum.MANAGER_ID)),
    ASSEMBLE(RedundantTemplateTypeEnum.ASSEMBLE.getCode(), Arrays.asList(AssembleEnum.ASSEMBLE_TIME, AssembleEnum.OUT_WAREHOUSE_ID_LINKED_TEXT, AssembleEnum.INTO_WAREHOUSE_ID_LINKED_TEXT, AssembleEnum.MANAGER_ID)),
    TRANSFER(RedundantTemplateTypeEnum.TRANSFER.getCode(), Arrays.asList(TransferEnum.TRANSFER_TIME, TransferEnum.OUT_WAREHOUSE_ID_LINKED_TEXT, TransferEnum.INTO_WAREHOUSE_ID_LINKED_TEXT, TransferEnum.MANAGER_NAME)),
    INVENTORY(RedundantTemplateTypeEnum.INVENTORY.getCode(), Arrays.asList(InventoryEnum.PRODUCT, InventoryEnum.TIME, InventoryEnum.WAREHOUSE_ID_LINKED_TEXT, InventoryEnum.MANAGER_ID)),
    INSTOCK(RedundantTemplateTypeEnum.INSTOCK.getCode(), Arrays.asList(InstockEnum.REF_ID_LINKED_TEXT, InstockEnum.TIME, InstockEnum.WAREHOUSE_ID_LINKED_TEXT, InstockEnum.MANAGER_ID)),
    OUTSTOCK(RedundantTemplateTypeEnum.OUTSTOCK.getCode(), Arrays.asList(OutstockEnum.REF_ID_LINKED_TEXT, OutstockEnum.TIME, OutstockEnum.WAREHOUSE_ID_LINKED_TEXT, OutstockEnum.MANAGER_ID)),
    PRODUCT(RedundantTemplateTypeEnum.PRODUCT.getCode(), Arrays.asList(ProductEnum.PRODUCT_IMGS, ProductEnum.PRODUCT_NO, ProductEnum.SPECIFICATION, ProductEnum.PRICE)),
    BOMBILL(RedundantTemplateTypeEnum.BOMBILL.getCode(), Arrays.asList(BomBillEnum.NAME, BomBillEnum.VERSION, BomBillEnum.MEMO)),
    PRODUCTIONORDER(RedundantTemplateTypeEnum.PRODUCTIONORDER.getCode(), Arrays.asList(ProductionOrderEnum.OUT_WAREHOUSE_ID_LINK_TEXT, ProductionOrderEnum.INTO_WAREHOUSE_ID_LINK_TEXT, ProductionOrderEnum.MEMO)),
    WORKREPORT(RedundantTemplateTypeEnum.WORKREPORT.getCode(), Arrays.asList(WorkReportFieldEnum.CONTENT, WorkReportFieldEnum.REPORT_DATE, WorkReportFieldEnum.CC)),
    COMMUNICATE(RedundantTemplateTypeEnum.COMMUNICATE.getCode(), Arrays.asList(CustomerCommunicateEnum.USER_NAME, CustomerCommunicateEnum.USER_AVATAR,CustomerCommunicateEnum.TYPE, CustomerCommunicateEnum.CUSTOMER_NAME_LINK_TEXT, CustomerCommunicateEnum.CONTACT_NAME_LINK_TEXT, CustomerCommunicateEnum.MEMO,
        CustomerCommunicateEnum.COMMUNICATE_BUSINESS_LINK_TEXT, CustomerCommunicateEnum.VIDEO, CustomerCommunicateEnum.IMAGES, CustomerCommunicateEnum.ADDRESS, CustomerCommunicateEnum.COMMUNICATE_TIME)),
    JXC_COMMUNICATE(RedundantTemplateTypeEnum.JXC_COMMUNICATE.getCode(), Arrays.asList(SupplierCommunicateEnum.USER_NAME, SupplierCommunicateEnum.USER_AVATAR,SupplierCommunicateEnum.TYPE, SupplierCommunicateEnum.SUPPLIER_NAME_LINK_TEXT, SupplierCommunicateEnum.SUPPLIER_CONTACT_NAME_LINK_TEXT, SupplierCommunicateEnum.MEMO,
        SupplierCommunicateEnum.COMMUNICATE_BUSINESS_LINK_TEXT, SupplierCommunicateEnum.VIDEO, SupplierCommunicateEnum.IMAGES, SupplierCommunicateEnum.ADDRESS, SupplierCommunicateEnum.COMMUNICATE_TIME)),
    COMMUNICATE_PLAN(RedundantTemplateTypeEnum.COMMUNICATE_PLAN.getCode(), Arrays.asList(CommunicatePlanEnum.STATUS, CommunicatePlanEnum.CREATOR_ID, CommunicatePlanEnum.TARGET, CommunicatePlanEnum.COMMUNICATE_TIME)),
    REFUND(RedundantTemplateTypeEnum.REFUND.getCode(), Arrays.asList(RefundEnum.REFUND_NAME, RefundEnum.SIGN_USER, RefundEnum.SIGN_DATE)),
    WORKORDER(RedundantTemplateTypeEnum.WORKORDER.getCode(), Arrays.asList(WorkOrderEnum.IMPLEMENTATION_TIME, WorkOrderEnum.LINK_CUSTOMER_HIDE, WorkOrderEnum.STATUS, WorkOrderEnum.ADDRESS)),
    DISTRIBUTOR_COMMUNICATE(RedundantTemplateTypeEnum.DISTRIBUTOR_COMMUNICATE.getCode(), Arrays.asList(DistributorCommunicateEnum.USER_NAME, DistributorCommunicateEnum.USER_AVATAR,DistributorCommunicateEnum.TYPE, DistributorCommunicateEnum.DISTRIBUTOR_NAME_LINK_TEXT, DistributorCommunicateEnum.CONTACT_NAME_LINK_TEXT, DistributorCommunicateEnum.MEMO,
            DistributorCommunicateEnum.COMMUNICATE_BUSINESS_LINK_TEXT, DistributorCommunicateEnum.VIDEO, DistributorCommunicateEnum.IMAGES, DistributorCommunicateEnum.ADDRESS, DistributorCommunicateEnum.COMMUNICATE_TIME)),
    UNKNOWN(RedundantTemplateTypeEnum.UNKNOWN.getCode(), new ArrayList<>()),
    ;

    private int businessType;
    private List<Object> attrList;

    MobileDetailSummaryEnum(int businessType, List<Object> attrList) {
        this.businessType = businessType;
        this.attrList = attrList;
    }

    /**
     * 通过业务类型获取枚举
     *
     * @param businessType 业务类型
     * @return MobileDetailSummaryEnum
     * @author GuoJun.HU
     * @date 2019/3/12 17:23
     * @since V1.0
     */
    public static MobileDetailSummaryEnum getByCode(Integer businessType) {
        for (MobileDetailSummaryEnum cacheCode : values()) {
            if (Objects.equals(businessType, cacheCode.getBusinessType())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

}
